package com.coding.controller;

import com.coding.base.pojo.BaseModel;
import com.coding.service.LocationService;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @auther wangchenghao
 * @date 2020/8/21
 **/
@Controller
@ResponseBody
@RequestMapping("location")
public class LocationController {
    @Autowired
    LocationService locationService;

    @ApiOperation("通过id查询坐标")
    @RequestMapping(value = "/getById", method = {RequestMethod.GET})
    public BaseModel getById(@ApiParam("id") @RequestParam(value = "id", required = true) Integer id) throws Exception {
        BaseModel model = new BaseModel();
        locationService.selectById(id, model);
        return model;
    }

    @ApiOperation("通过name查询坐标")
    @RequestMapping(value = "/getByName", method = {RequestMethod.GET})
    public BaseModel getByName(@ApiParam("地名") @RequestParam(value = "name", required = true) String name) throws Exception {
        BaseModel model = new BaseModel();
        locationService.selectByName(name, model);
        return model;
    }
}
